package im.yisme.view.ui.animation;

import im.yisme.view.ui.RecordView;
import im.yisme.view.ui.animation.pojo.LinePOJO;

import java.util.ArrayList;

import android.util.Log;
/**
 * Tail动画逻辑
 * @author Max
 *
 */

public class Tail extends Thread{

private ArrayList<LinePOJO> list;
private boolean isAlive;
private boolean isRunning;
private static final int FADING_INTERVAL=50;
private static final int PAUSE_POLLING_INTERVAL=500;
	public Tail(ArrayList<LinePOJO> list){
		this.list=list;
		isAlive=true;
		isRunning=true;
	}
	public void run(){
		
		try {
			while(isAlive){
				
				if(!isRunning){
					Thread.sleep(PAUSE_POLLING_INTERVAL);
					continue;
				}
				
				if(list.size() == 0) {
					Thread.sleep(PAUSE_POLLING_INTERVAL);
				}
				else {
					list.remove(list.size()-1);
					Thread.sleep(FADING_INTERVAL);
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		
	}
	public void stopRunning(){
		isAlive=false;
	}
	public void pauseRunning(){
		isRunning=false;
	}
	public void resumeRunning(){
		isRunning=true;
	}
}
